package com.kefu.chat.vo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.kefu.chat.model.ChatAdminStatus;
import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.Objects;


@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "客服状态切换")
public class ChatAdminStatusSearchVo extends AbstractSearchVo {
    @ApiModelProperty(value = "坐席id")
    private String adminId;
	@ApiModelProperty(value = "客服状态：0离线，1在线，2忙碌")
	private Integer statusType;
	@ApiModelProperty(value = "状态时间开始")
	private Long statusTimeStart;
	@ApiModelProperty(value = "状态时间结束")
	private Long statusTimeEnd;

	@Override
	public LambdaQueryWrapper<ChatAdminStatus> lambdaQuery() {
		LambdaQueryWrapper<ChatAdminStatus> wrapper = Wrappers.lambdaQuery(ChatAdminStatus.class);
		wrapper.eq(StrUtil.isNotBlank(adminId), ChatAdminStatus::getAdminId, adminId)
				.ge(Objects.nonNull(statusTimeStart), ChatAdminStatus::getStatusTime, statusTimeStart)
				.le(Objects.nonNull(statusTimeEnd), ChatAdminStatus::getStatusTime, statusTimeEnd)
				.eq(Objects.nonNull(statusType), ChatAdminStatus::getStatusType, statusType)
				.eq(ChatAdminStatus::getTenantId, KefuContext.getTid())
				.orderByDesc(ChatAdminStatus::getStatusTime);
		return wrapper;
	}
}